package team.seekers.catering.order.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import team.seekers.catering.common.result.R;
import team.seekers.catering.common.result.ResultCode;
import team.seekers.catering.common.utils.ParamCheckUtil;
import team.seekers.catering.order.entity.dto.add.FeedbackAddDTO;
import team.seekers.catering.order.service.FeedbackService;
import team.seekers.catering.user.service.UserService;

import javax.validation.Valid;

/**
 * <p>
 * 用户反馈表 前端控制器
 * </p>
 *
 * @author hbc
 * @since 2022-03-02
 */
@RestController
@RequestMapping("/feedback")
public class FeedbackController {

    @Autowired
    private FeedbackService feedbackService;
    @Autowired
    private UserService userService;

    @PostMapping("/add")
    public R add(@RequestBody @Valid FeedbackAddDTO feedbackAddVO){
        if(feedbackAddVO.getOrderId() != null){
            if(ParamCheckUtil.isNotRightId(feedbackAddVO.getOrderId())){
                return R.fail(ResultCode.PARAM_NOT_VALID).message("订单id不规范");
            }
        }
//        if(FeedbackTypeEnum.getByType(feedbackAddVO.getType()) == null){
//            return R.fail(ResultCode.PARAM_NOT_VALID).message("投诉类型不规范");
//        }
        boolean add = feedbackService.add(feedbackAddVO);
        if(!add){
            return R.fail(ResultCode.GET_FAIL);
        }
        return R.success();
    }

}

